#define DEBUG
#include <cstdio>
#include <cstring>
#define MAXN 50

using namespace std;

void sort(int *a, int *b, int l, int r) {
  int i=l, j=r, mid=a[(l+r)/2], temp;
  for (; i<=j; ) {
    for (; a[j]>mid; j--);
    for (; a[i]<mid; i++);
    if (i<=j) {
      temp=a[i], a[i]=a[j], a[j]=temp;
      temp=b[i], b[i]=b[j], b[j]=temp;
      i++, j--;
    }
  }
  if (i<r) {
    sort(a, b, i, r);
  }
  if (j>l) {
    sort(a, b, l, j);
  }
}

int min(int a, int b) {
  return a<b ? a : b;
}

int main() {
#ifdef DEBUG
  freopen("1.in", "r", stdin);
  freopen("1.out", "w", stdout);
#endif

  static int a[MAXN+1], g[MAXN+1];
  int n, h;
  scanf("%d %d", &n, &h);
  for (int i=1; i<=n; i++) {
    scanf("%d", a+i);
  }
  for (int i=1; i<=n; i++) {
    scanf("%d", g+i);
  }

  sort(g, a, 1, n);

  static int f[MAXN+1][MAXN+1][MAXN+1];
  memset(f, 126, sizeof(f));
  f[0][0][0]=0;
  for (int i=1; i<=n; i++) {
    f[0][i][0] = f[0][i-1][0]+a[i];
  }
  if (f[0][n][0]<=h) {
    printf("0");
    return 0;
  }

  for (int i=1; i<=n; i++) {
    int x=0;
    for (int j=1; j<=n; j++) {
      f[i][j][0] = f[i-1][j][0]+x+g[j];
      for (int k=1; k<=i; k++) {
	f[i][j][k] = min(f[i][j-1][k]+a[j]+g[j]*i, min(f[i-1][j][k]+x+g[j], f[i-1][j-1][k-1]+x));
      }
      x += g[j];
    }
    if (f[i][n][i]<=h) {
      printf("%d", i);
      return 0;
    }
  }

  printf("-1");

  fclose(stdin);
  fclose(stdout);
  return 0;
}
